'use strict'
const path = require("path");
function resolve(dir) {
    return path.join(__dirname, dir);
}

module.exports = {
    devServer: {
        port:9526,
        open: true,
        overlay: {
            warnings: false,
            errors: true
        },
        proxy: {
            // 代理 /dev-api/user/login 到 http://localhost:3000//user/login
            [process.env.VUE_APP_BASE_API]: {
                target: `http://localhost:3000/`,
                changeOrigin: true,
                pathRewrite: {
                    ["^" + process.env.VUE_APP_BASE_API]: ""
                }
            }
        },
        // before: require('./mock/mock-server.js')
    },
    configureWebpack: {
        // provide the app's title in webpack's name field, so that
        // it can be accessed in index.html to inject the correct title.
        name: '后台管理系统',
        resolve: {
            alias: {
                '@': resolve('src')
            }
        }
    },
    chainWebpack: config => {
        // 清除svg默认配置对./src/icons文件夹的处理
        config.module
            .rule("svg")
            .exclude.add(resolve("src/assets/icons")) // icons存放地（svg放的地方）
            .end()

        // 添加新的rule处理./src/icons文件夹的svg文件
        config.module
            .rule("svg-sprite")
            .test(/\.svg$/)
            .include
            .add(resolve("src/assets/icons"))
            .end()
            .use("svg-sprite-loader")
            .loader("svg-sprite-loader")
            .options({
                symbolId: "icon-[name]",
                include: ["src/assets/icons"]
            })
            .end()
            .before("svg-sprite-loader")
            .use("svgo-loader")
            .loader("svgo-loader")
            .options({
                plugins: [
                    { removeAttrs: { attrs: "path:fill" } }
                ]
            })
            .end()
    },

}
